﻿
<template>
<div class="card-fill layout-padding">
<el-card shadow="hover" class="layout-padding-auto" >
  <WtmSearcher v-model="searchDataSpcAnalysis" @search="()=>{getTableDataSpcAnalysis();}">
      <el-row>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Code_FormItem" prop="Code" :label="$t('message.autotrans._Model_SpcAnalysis_Code')">
            <el-input v-model="searchDataSpcAnalysis.Code" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Desc_FormItem" prop="Desc" :label="$t('message.autotrans._Model_SpcAnalysis_Desc')">
            <el-input v-model="searchDataSpcAnalysis.Desc" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ChartType_FormItem" prop="ChartType" :label="$t('message.autotrans._Model_SpcAnalysis_ChartType')">
            <el-select v-model="searchDataSpcAnalysis.ChartType" clearable>
               <el-option key="C" value="C" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_C')"></el-option>
               <el-option key="C_U" value="C_U" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_C_U')"></el-option>
               <el-option key="NP_P" value="NP_P" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_NP_P')"></el-option>
               <el-option key="Xbar_R_Xbar_S" value="Xbar_R_Xbar_S" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_Xbar_R_Xbar_S')"></el-option>
               <el-option key="U" value="U" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_U')"></el-option>
               <el-option key="NP" value="NP" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_NP')"></el-option>
               <el-option key="P" value="P" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_P')"></el-option>
               <el-option key="I_MR" value="I_MR" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_I_MR')"></el-option>
               <el-option key="Xbar_S" value="Xbar_S" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_Xbar_S')"></el-option>
               <el-option key="Xbar_R" value="Xbar_R" :label="$t('message.autotrans._Enum_SpcChartTypeEnum_Xbar_R')"></el-option>
            </el-select>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductId_FormItem" prop="ProductId" :label="$t('message.autotrans._Model_SpcAnalysis_ProductId')">
            <el-input v-model="searchDataSpcAnalysis.ProductId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ProductName_FormItem" prop="ProductName" :label="$t('message.autotrans._Model_SpcAnalysis_ProductName')">
            <el-input v-model="searchDataSpcAnalysis.ProductName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpId_FormItem" prop="OpId" :label="$t('message.autotrans._Model_SpcAnalysis_OpId')">
            <el-input v-model="searchDataSpcAnalysis.OpId" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="OpName_FormItem" prop="OpName" :label="$t('message.autotrans._Model_SpcAnalysis_OpName')">
            <el-input v-model="searchDataSpcAnalysis.OpName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="ChartName_FormItem" prop="ChartName" :label="$t('message.autotrans._Model_SpcAnalysis_ChartName')">
            <el-input v-model="searchDataSpcAnalysis.ChartName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DataName_FormItem" prop="DataName" :label="$t('message.autotrans._Model_SpcAnalysis_DataName')">
            <el-input v-model="searchDataSpcAnalysis.DataName" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="DataTag_FormItem" prop="DataTag" :label="$t('message.autotrans._Model_SpcAnalysis_DataTag')">
            <el-input v-model="searchDataSpcAnalysis.DataTag" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="SimpleQty_FormItem" prop="SimpleQty" :label="$t('message.autotrans._Model_SpcAnalysis_SimpleQty')">
            <el-input v-model="searchDataSpcAnalysis.SimpleQty" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UCL_FormItem" prop="UCL" :label="$t('message.autotrans._Model_SpcAnalysis_UCL')">
            <el-input v-model="searchDataSpcAnalysis.UCL" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CL_FormItem" prop="CL" :label="$t('message.autotrans._Model_SpcAnalysis_CL')">
            <el-input v-model="searchDataSpcAnalysis.CL" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LCL_FormItem" prop="LCL" :label="$t('message.autotrans._Model_SpcAnalysis_LCL')">
            <el-input v-model="searchDataSpcAnalysis.LCL" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="USL_FormItem" prop="USL" :label="$t('message.autotrans._Model_SpcAnalysis_USL')">
            <el-input v-model="searchDataSpcAnalysis.USL" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="LSL_FormItem" prop="LSL" :label="$t('message.autotrans._Model_SpcAnalysis_LSL')">
            <el-input v-model="searchDataSpcAnalysis.LSL" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="Remark_FormItem" prop="Remark" :label="$t('message.autotrans._Model_SpcAnalysis_Remark')">
            <el-input v-model="searchDataSpcAnalysis.Remark" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateTime_FormItem" prop="CreateTime" :label="$t('message.autotrans._Model_SpcAnalysis_CreateTime')">
            <el-date-picker v-model="searchDataSpcAnalysis.CreateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateTime_FormItem" prop="UpdateTime" :label="$t('message.autotrans._Model_SpcAnalysis_UpdateTime')">
            <el-date-picker v-model="searchDataSpcAnalysis.UpdateTime" type='daterange' clearable></el-date-picker>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="CreateBy_FormItem" prop="CreateBy" :label="$t('message.autotrans._Model_SpcAnalysis_CreateBy')">
            <el-input v-model="searchDataSpcAnalysis.CreateBy" clearable></el-input>
        </el-form-item>

        </el-col>
        <el-col :xs="24" :lg="8" class="mb20">
        <el-form-item ref="UpdateBy_FormItem" prop="UpdateBy" :label="$t('message.autotrans._Model_SpcAnalysis_UpdateBy')">
            <el-input v-model="searchDataSpcAnalysis.UpdateBy" clearable></el-input>
        </el-form-item>

        </el-col>
      </el-row>

  </WtmSearcher>

  <div style="text-align: right;">
      <WtmButton v-auth="'/api/SpcManagement/SpcAnalysis/Create'" icon='fa fa-plus' type='primary' :button-text="$t('message.autotrans.SysCreate')" @click="OnCreateClick()"/>
    <WtmButton v-auth="'/api/SpcManagement/SpcAnalysis/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" @click="onBatchDelete()"/>
    <WtmButton v-auth="'/api/SpcManagement/SpcAnalysis/BatchEdit'" icon='fa fa-pencil-square' type='primary' :button-text="$t('message.autotrans.SysBatchEdit')" @click="OnBatchEditClick()"/>
    <WtmButton v-auth="'/api/SpcManagement/SpcAnalysis/Import'" icon='fa fa-tasks' type='primary' :button-text="$t('message.autotrans.SysImport')" @click="OnImportClick()"/>
    <WtmButton v-auth="'/api/SpcManagement/SpcAnalysis/SpcAnalysisExportExcel'"  icon='fa fa-arrow-circle-down' type='primary' :button-text="$t('message.autotrans.SysExport')" @click="onExport()"/>

  </div>
  <WtmTable ref="tableRefSpcAnalysis" v-bind="tableDataSpcAnalysis">
    <template #operation>
      <el-table-column :label="$t('message._system.common.vm.operate')" width="180">
        <template v-slot="scope">
            <WtmButton v-auth="'/api/SpcManagement/SpcAnalysis/Edit'" :is-text="true" icon='fa fa-pencil-square' type='warning' :button-text="$t('message.autotrans.SysEdit')" @click="OnEditrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/SpcManagement/SpcAnalysis/{id}'" :is-text="true" icon='fa fa-info-circle' type='info' :button-text="$t('message.autotrans.Page详情')" @click="OnDetailsrowClick(scope.row)"/>
          <WtmButton v-auth="'/api/SpcManagement/SpcAnalysis/BatchDelete'"  icon='fa fa-trash' type='danger' :button-text="$t('message.autotrans.SysDelete')" :confirm="$t('message._system.common.vm.deletetip')" :is-text="true"  @click="onDelete(scope.row)"/>

        </template>
      </el-table-column>
    </template>
  </WtmTable>

</el-card>
</div>
</template>


<script setup lang="ts" name="message.autotrans._PageSpcManagementSpcAnalysisIndex;true;Digitalmes.SpcManagement.Controllers;SpcAnalysis">
import {  ElMessageBox, ElMessage,ElLoading } from 'element-plus';
import { defineAsyncComponent,reactive, ref, getCurrentInstance, onMounted, nextTick } from 'vue';
import { spcanalysisApi } from '/@/api/spcmanagement/spcanalysis';
import other from '/@/utils/other';
import fileApi from '/@/api/file';
import { useRouter } from "vue-router";
const ci = getCurrentInstance() as any;

const CreateDialog = defineAsyncComponent(() => import('./create.vue'));
const EditDialog = defineAsyncComponent(() => import('./edit.vue'));
const DetailsDialog = defineAsyncComponent(() => import('./details.vue'));
const BatchEditDialog = defineAsyncComponent(() => import('./batchedit.vue'));
const ImportDialog = defineAsyncComponent(() => import('./import.vue'));

const stateSpcAnalysis = reactive({
    
});

const searchDataSpcAnalysis = ref({
        Code: '',
        Desc: '',
        ChartType: undefined,
        ProductId: null,
        ProductName: '',
        OpId: null,
        OpName: '',
        ChartName: '',
        DataName: '',
        DataTag: '',
        SimpleQty: null,
        UCL: null,
        CL: null,
        LCL: null,
        USL: null,
        LSL: null,
        Remark: '',
        CreateTime: undefined,
        UpdateTime: undefined,
        CreateBy: '',
        UpdateBy: '',
});

// 定义变量内容
const tableRefSpcAnalysis = ref();
const tableDataSpcAnalysis = ref({
    // 列表数据（必传）
    data: [],
	// 表头内容（必传，注意格式）
	header: [
      {title:ci.proxy.$t('message.autotrans.Page表单编号'),key: 'SpcAnalysis_Code',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page表单描述'),key: 'SpcAnalysis_Desc',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page控制图样式'),key: 'SpcAnalysis_ChartType',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品'),key: 'SpcAnalysis_ProductId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page产品名称'),key: 'SpcAnalysis_ProductName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工序'),key: 'SpcAnalysis_OpId',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page工序名称'),key: 'SpcAnalysis_OpName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page图表名称'),key: 'SpcAnalysis_ChartName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page数据名称'),key: 'SpcAnalysis_DataName',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page数据Tag'),key: 'SpcAnalysis_DataTag',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page抽样数量'),key: 'SpcAnalysis_SimpleQty',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page上控制限'),key: 'SpcAnalysis_UCL',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page中心线'),key: 'SpcAnalysis_CL',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page下控制限'),key: 'SpcAnalysis_LCL',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page规格上限'),key: 'SpcAnalysis_USL',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans.Page规格下限'),key: 'SpcAnalysis_LSL',type: 'text',isCheck: true},
      {title:ci.proxy.$t('message.autotrans._AdminRemark'),key: 'SpcAnalysis_Remark',type: 'text',isCheck: true},

	],
	// 配置项（必传）
	config: {
        total: 0, // 列表总数
		loading: true, // loading 加载
		isSerialNo: true, // 是否显示表格序号
		isSelection: true, // 是否显示表格多选
		isOperate: true, // 是否显示表格操作栏
	}
});
// 初始化表格数据
const getTableDataSpcAnalysis = () => {
    tableRefSpcAnalysis.value.doSearch(spcanalysisApi().search, searchDataSpcAnalysis.value)
        .catch((error: any) => {
			other.setFormError(ci, error);
		});
};
const OnCreateClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysCreate'), CreateDialog, null, getTableDataSpcAnalysis)
};

const OnEditrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysEdit'), EditDialog, row, getTableDataSpcAnalysis)
};

const OnDetailsrowClick = (row: any) => {
    other.openDialog(ci.proxy.$t('message.autotrans.Page详情'), DetailsDialog, row, getTableDataSpcAnalysis)
};

// 删除
const onDelete = (row: any) => {
    spcanalysisApi().delete([row.ID]).then(() => { getTableDataSpcAnalysis()})
};

const onBatchDelete = () => {
    const selectedrows = tableRefSpcAnalysis.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      spcanalysisApi().delete(selectedids).then(() => { getTableDataSpcAnalysis()})
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnBatchEditClick = () => {
    const selectedrows = tableRefSpcAnalysis.value.getSelectedRows();
    const selectedids = selectedrows.map((x: any) => x.ID);
    if (selectedids.length > 0)
      other.openDialog(ci.proxy.$t('message.autotrans.SysBatchEdit'), BatchEditDialog, selectedids, getTableDataSpcAnalysis)
    else
      ElMessage.error(ci.proxy.$t('message._system.common.vm.check'));
};

const OnImportClick = () => {
    other.openDialog(ci.proxy.$t('message.autotrans.SysImport'), ImportDialog, null, getTableDataSpcAnalysis)
};

const onExport = () => {
	const selected = tableRefSpcAnalysis.value.getSelectedRows();
	if (selected.length > 0) {
		spcanalysisApi().exportById(selected.map((x: any) => x.ID));
	}
	else {
		spcanalysisApi().export({});
	}
};

// 页面加载时
onMounted(() => {
    
        getTableDataSpcAnalysis();

});

// 暴露变量
defineExpose({

});
</script>

<style scoped lang="scss">

</style>

